# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=astroid
pkgbase=mingw-w64-python3-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=2.3.2
pkgrel=1
pkgdesc="Useful miscellaneous modules used by Logilab projects (mingw-w64)"
arch=('any')
url="https://github.com/PyCQA/astroid"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-python3-six"
         "${MINGW_PACKAGE_PREFIX}-python3-lazy-object-proxy"
         "${MINGW_PACKAGE_PREFIX}-python3-wrapt"
         "${MINGW_PACKAGE_PREFIX}-python3-typed_ast")
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python3-dateutil"
              "${MINGW_PACKAGE_PREFIX}-python3-pytest"
              "${MINGW_PACKAGE_PREFIX}-python3-numpy"
              "${MINGW_PACKAGE_PREFIX}-python3-nose"
              "${MINGW_PACKAGE_PREFIX}-python3-pytest-runner")
source=(https://github.com/PyCQA/astroid/archive/astroid-${pkgver}.tar.gz)
sha512sums=('73ed8213f25a76aa60703320aaf290db33ac005e0ded26fe50c7f36bd934f98c3a58e928becc4e601d3879c19a0f0f16bf20764e3a24e227e0fb64179e468732')

prepare() {
  cd "${srcdir}"
   rm -rf "python3-build-${CARCH}" | true
   cp -r "${_realname}-${_realname}-${pkgver}" "python3-build-${CARCH}"
  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
}

build() {
  msg "Python 3 build for ${CARCH}"  
  cd "${srcdir}/python3-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python3 setup.py build
}

check() {
  msg "Python 3 test for ${CARCH}"
  cd "${srcdir}/python3-build-${CARCH}"
  ${MINGW_PREFIX}/bin/pytest || warning "Tests failed"
}

package() {
  cd "${srcdir}/python3-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

}
